package com.wyz.saas.common.notifice.receiver

import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import com.wyz.saas.common.R

class CopyReceiver : AtomBroadcastReceiver<String>(ACTION_ID) {

    companion object{
        private const val ACTION_ID = "com.wyz.saas.common.notifice.receiver.CopyReceiver"
    }

    override fun handle(ctx: Context, data: String) {
        // Copy the link to the clipboard.
        val clip = ClipData.newPlainText(ctx.getString(R.string.action_copied), data)
        (ctx.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager).also {
            it.setPrimaryClip(clip)
        }
    }
}